<template>
    <div id="backLeftBar" ref="backLeftBar">
        <h1>后台管理</h1>
        <el-menu class="el-menu-vertical-demo" background-color="#363a3d" text-color="#fff"
            active-text-color="rgb(255, 150, 50)" :default-openeds="['2']">
            <el-menu-item index="1" @click="toBack">
                <i class="el-icon-s-data"></i>
                <span slot="title">首页</span>
            </el-menu-item>
            <el-submenu index="2">
                <template slot="title">
                    <i class="el-icon-coin"></i>
                    <span>内容管理</span>
                </template>
                <el-menu-item-group>
                    <el-menu-item index="2-1" @click="toArticle">文章管理</el-menu-item>
                    <el-menu-item index="2-2" @click="toEssay">随笔管理</el-menu-item>
                    <el-menu-item index="2-3" @click="toResource">资源管理</el-menu-item>
                    <el-menu-item index="2-4" @click="toAnnouncement">公告管理</el-menu-item>
                    <el-menu-item index="2-5" @click="toPhoto">图库管理</el-menu-item>
                </el-menu-item-group>
            </el-submenu>
            <el-menu-item index="3" @click="toTimer">
                <i class="el-icon-alarm-clock"></i>
                <span slot="title">计时卡片</span>
            </el-menu-item>
            <el-menu-item index="4" @click="toWish">
                <i class="el-icon-collection-tag"></i>
                <span slot="title">心愿清单</span>
            </el-menu-item>
            <el-menu-item index="5" @click="toAdministrator">
                <i class="el-icon-s-custom"></i>
                <span slot="title">管理员管理</span>
            </el-menu-item>
        </el-menu>
    </div>
</template>

<script>
export default {
    methods: {
        // 跳转到网站数据页
        toBack() {
            this.$router.push({
                path: "/back"
            })
        },
        // 跳转到管理员管理页面
        toAdministrator() {
            this.$router.push({
                path: "/back/administrator"
            })
        },
        // 跳转到文章管理页面
        toArticle() {
            this.$router.push({
                path: "/back/article"
            })
        },
        // 跳转到随笔管理页面
        toEssay() {
            this.$router.push({
                path: "/back/essay"
            })
        },
        // 跳转到资源管理页面
        toResource() {
            this.$router.push({
                path: "/back/resource"
            })
        },
        // 跳转到公告管理页面
        toAnnouncement() {
            this.$router.push({
                path: "/back/announcement"
            })
        },
        toWish() {
            this.$router.push({
                path: "/back/wish"
            })
        },
        toPhoto() {
            this.$router.push({
                path: "/back/photo"
            })
        },
        toTimer() {
            this.$router.push({
                path: "/back/timer"
            })
        }
    },
    mounted() {
        // 获取当前屏幕高度，并设置leftBar的最小高度为一个屏幕高度 (减去30是因为window.innerHeight大于一个屏幕高度，目测感觉减30刚刚好)
        this.$refs.backLeftBar.style.minHeight = window.innerHeight + 'px'
    }
}
</script>

<style lang="scss" scoped>
h1 {
    margin: 20px auto;
    text-align: center;
    color: #fff;
    font-size: $font-size-large;
    font-weight: $font-weight-large;
}

#backLeftBar {
    background-color: #363a3d;
    overflow: hidden;
}
</style>
<style scoped="scope" scope>
/deep/.el-menu {
    border-right: none;
}
</style>